import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { StudentVo } from '../vo/studentvo';

@Injectable()
export class StudentService {

  constructor(private http:HttpClient) { }


  private getAnObjectUrl="http://localhost:8080/getAnObject";

  getAnObject(){

    return this.http.get(this.getAnObjectUrl).toPromise();
  }

  private addStudentUrl="http://localhost:8080/saveStudentInfo";

addStudentInfo(svo:StudentVo){
let p={
  "studentid":svo.studentid,
	"xm":svo.xm,
	"sfzh":svo.sfzh,
	"xh":svo.xh,
   }
return this.http.post(this.addStudentUrl,p).toPromise();
 }
 
 private getStudentListUrl="http://localhost:8080/getStudentList";
    getStudentList(){
       return this.http.get(this.getStudentListUrl).toPromise();
  }

 private getSingleStudentUrl="http://localhost:8080/getSingleStudentById";
  getSingleStudent(id:string){
  let p={
    "studentid":id
  } 
    return this.http.post(this.getSingleStudentUrl,p).toPromise();
  }

  private deleteStudentUrl="http://localhost:8080/deleteStudent";
  deleteStudent(id:string){
    let p={
      "studentid":id
    }
    return this.http.post(this.deleteStudentUrl,p).toPromise();
  }











}
